package com.data.web.constant;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel
public class ResultVo<T> {

    public static final int FAILURE = 100;//操作失败
    public static final int NO_MAPPING = 101;//Not Found 请求资源不存在
    public static final int MethodNotSupport = 102;//请求方法错误
    public static final int ERROR = 110;//请求发生错误，请联系开发人员
    public static final int SUCCESS = 200;//请求成功
    public static final int REQUIRED = 300;//参数为空
    public static final int PARAMETER_INVALID = 301;//参数错误
    public static final int NO_TOKEN = 400;//没有提供凭证
    public static final int EXPIRE = 401;//凭证过期
    public static final int ILLEGAL_TOKEN = 402;//凭证不合法
    public static final int EMPTY_DATA = 5000;//暂无数据

    @ApiModelProperty(value = "key",example = "200")
    private int key;
    @ApiModelProperty(value = "返回信息",example = "成功")
    private String message;
    @ApiModelProperty(value = "返回数据",example = "")
    private T data;

    public ResultVo(int key, String message){
        this.key = key;
        this.message = message;
    }

    public static ResultVo success(){
        return new ResultVo(ResultVo.SUCCESS,"成功");
    }

    public static <T> ResultVo success(T data){
        return new ResultVo(ResultVo.SUCCESS,"成功",data);
    }

    public static ResultVo fail(){
        return new ResultVo(ResultVo.FAILURE,"失败");
    }

    public static ResultVo fail(String message){
        return new ResultVo(ResultVo.FAILURE,message);
    }


}
